<?php

namespace haibao\app\data;

class RequestHistory extends \haibao\app\data\Base{

	public function __construct(){
		parent::__construct('\haibao\app\model\data\RequestHistory');
	}
    
	/**
	 * 添加访问记录
	 * @param \haibao\app\model\data\RequestHistory $requestHistoryModel
	 */
	public function addRequestHistory($requestHistoryModel){
		$this->setTableName($requestHistoryModel);
		$this->createApiRequestHistoryTable($requestHistoryModel->getTableName());
		$this->add($requestHistoryModel);
	}
	
	public function addErrorMsg($userId,$systemType,$model,$content){
		$userId = (int)$userId;
		$systemType = (int)$systemType;
		$sql = 'insert into ErrorMsg (UserId, SystemType,Model,ErrorMessage,CreateTime) values (%s,%s,%s,%s,%s)';
		$this->query($sql, array(
		    $userId, $systemType, $model, $content, date('Y-m-d H:i:s')
		));
	}
}